﻿using System;
using System.Diagnostics;
using System.Windows.Forms;
using pvmoduleditor.contracts;
using pvmoduleditor.contracts.viewmodels;

namespace pvmoduleditor.gui
{
    public partial class StartGui : Form, IStartGui
    {
        public StartGui()
        {
            InitializeComponent();
        }

        public event Action Result;

        public void Process(StartGuiViewModel p_StartGuiViewModel)
        {
            Trace.TraceInformation("pvmoduleditor.gui.Process");
            lVPVModule.Clear();
            init_Header();

            foreach (PVModulReduziert tmp_modul in p_StartGuiViewModel.PVModulReduziertListe)
            {
                var tmp_Item = new ListViewItem(tmp_modul.Hersteller);
                tmp_Item.SubItems.Add(tmp_modul.Artikelnummer);
                tmp_Item.SubItems.Add(tmp_modul.Typ);
                tmp_Item.SubItems.Add(tmp_modul.Leistung_W);
                lVPVModule.Items.Add(tmp_Item);
            }
        }

        private void init_Header()
        {
            Trace.TraceInformation("pvmoduleditor.gui.init_Header");
            lVPVModule.Columns.Add("Hersteller");
            lVPVModule.Columns.Add("Artikelnummer");
            lVPVModule.Columns.Add("Typ");
            lVPVModule.Columns.Add("Leistung_W");
        }

        private void StartGui_Load(object sender, EventArgs e)
        {
            Trace.TraceInformation("pvmoduleditor.gui.StartGui_Load");
            Result();
        }

    }
}
